const cloud = require('wx-server-sdk')

cloud.init({
    env:'zncwg-6gwftupofb14f74e'
})
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  return await db.collection('Udata').aggregate()
  .lookup({
    from:'userdata',
    localField:'user',
    foreignField:'_id',
    as:'ghList'
  }) 
  .sort({
    '_createTime': -1 // 倒序
  })
  .end()
}